﻿using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;

namespace Marmat.Forms
{
    public class BarSubItem : BarItem
    {
        private DevExpress.XtraBars.BarSubItem _BarSubItem;


        public BarSubItem() : base(new DevExpress.XtraBars.BarSubItem())
        {
            this._BarSubItem = (DevExpress.XtraBars.BarSubItem)barItem;
            this._BarSubItem.Popup += this.RaiseEventPopup;
        }

        [EditorBrowsable(EditorBrowsableState.Always)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        [Localizable(true)]
        [NotifyParentProperty(true)]
        [Category("数据")]
        [Description("返回 Table 的列集合")]
        public BarItemCollection Items
        {
            get
            {
                if (this._Items is null)
                {
                    DevExpress.XtraBars.BarSubItem Item = (DevExpress.XtraBars.BarSubItem)this.barItem;
                    this._Items = new BarItemCollection(this.barItem.Manager, Item.LinksPersistInfo, this);
                }
                return this._Items;
            }
        }

        private BarItemCollection _Items;

        public event EventHandler Popup;

        internal void RaiseEventPopup(object sender, EventArgs e)
        {
            Popup?.Invoke(sender, e);
        }
    }
}